package com.zhang.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.pojo.InputInfoAndOrder;
import com.zhang.pojo.InputInfoBean;
import com.zhang.service.IInputInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Api(tags = "采购信息控制层接口")
@RestController
@RequestMapping("inputInfo")
public class InputInfoController {

    @Autowired
    private IInputInfoService inputInfoService;

    @ApiOperation("通过供应商,起始日期,结束日期动态条件查询，并分页")
    @GetMapping("findByPageAndItem")
    public IPage<InputInfoBean> findByPageAndItem(int current,
                                                  int pageSize,
                                                  String name,
                                                  LocalDate start,
                                                  LocalDate end) {
        return inputInfoService.findByItem(new Page<>(current, pageSize), name, start, end);
    }

    @ApiOperation("根据采购信息id查询详情")
    @GetMapping("findById")
    public InputInfoAndOrder findById(int id) {
        return inputInfoService.findById(id);
    }
}
